library(dplyr)
library(lavaan)
library(DiagrammeR)
library(ggplot2)
library(tidyr)
combined=read.csv("data/monthly_averages/monthly_data_compiled_regions.csv",stringsAsFactors = F)
cnames=read.csv("analysis/column_names_region_monthly.csv", stringsAsFactors = F)
dsub=filter(combined, Year>=1995) %>% arrange(Region,Year,Month)
focaldata=dsub[,cnames$Datacolumn]
fvars=cnames$Shortname
colnames(focaldata)=fvars
regions=unique(focaldata$region)
regionorder=c("Far West","West","North","South")
focaldata=focaldata%>%
mutate(decyear=year+(month-1)/12)
focaldata = focaldata %>%
mutate(tzoop=hcope+clad+mysid+pcope+rotif_m,
tzoop_e=hcope_e+clad_e+mysid_e+pcope_e+rotif_e,
hzoop=hcope+clad+rotif_m,
hzoop_e=hcope_e+clad_e+rotif_e,
pzoop=mysid+pcope,
pzoop_e=mysid_e+pcope_e)
fvars=c(fvars,"tzoop","tzoop_e",
"hzoop","hzoop_e",
"pzoop","pzoop_e")
cnames=rbind(cnames,data.frame(Longname=NA,Shortname=c("tzoop","tzoop_e",
"hzoop","hzoop_e",
"pzoop","pzoop_e"),
Diagramname=c("Total Zooplankton\nBiomass",
"Total Zooplankton\nEnergy",
"Herbivorous Zooplankton\nBiomass",
"Herbivorous Zooplankton\nEnergy",
"Predatory Zooplankton\nBiomass",
"Predatory Zooplankton\nEnergy"),
Datacolumn=NA,Log="yes"))
#focal variables
varnames=c("temp","flow","secchi","dophos","din","chla","hcope","clad","amphi","pcope","mysid","rotif_m","potam","corbic","sside","cent","marfish_bsmt","estfish_bsmt","tzoop","hzoop","pzoop")
#labels for lagged vars
cnameslag=cnames
cnameslag$Shortname=paste0(cnameslag$Shortname,"_1")
cnameslag$Diagramname=paste(cnameslag$Diagramname,"(t-1)")
cnameslag=rbind(cnames,cnameslag)
source("analysis/myLavaanPlot.r")
Log transform, scale.
Within and across regions.
Create set with regional monthly means removed.
#log transform
logvars=fvars[cnames$Log=="yes"]
logtrans=function(x) {
x2=x[which(!is.na(x))]
if(any(x2==0)) {log(x+min(x2[which(x2>0)],na.rm=T))}
else {log(x)}
}
focaldatalog = focaldata %>%
mutate_at(logvars,logtrans)
#scale data
fdr0=focaldatalog
tvars=fvars[-(1:3)]
#scaled within regions
fdr=fdr0 %>%
group_by(region) %>%
#scale
mutate_at(tvars,scale) %>%
#lag
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
#scaled within regions, remove monthly means
fdr_ds=fdr %>%
group_by(region,month) %>%
mutate_at(tvars,list("mm"=function(x) {mean(x,na.rm = T)})) %>%
mutate_at(tvars,function(x) {x-mean(x,na.rm = T)}) %>%
ungroup() %>%
#lag
group_by(region) %>%
mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
ungroup() %>%
as.data.frame()
#scaled across regions
# fdr1=fdr0 %>%
# #scale
# mutate_at(tvars,scale) %>%
# #lag
# group_by(region) %>%
# mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
# ungroup() %>%
# as.data.frame()
#scaled across regions, monthly means removed
# fdr1_ds=fdr1 %>%
# group_by(region,month) %>%
# mutate_at(tvars,list("mm"=function(x) {mean(x,na.rm = T)})) %>%
# mutate_at(tvars,function(x) {x-mean(x,na.rm = T)}) %>%
# ungroup() %>%
# #lag
# group_by(region) %>%
# mutate_at(tvars,list("1"=lag,"2"=function(x) {lag(x,2)})) %>%
# ungroup() %>%
# as.data.frame()
Exclude individual zooplankton plankton groups from zooplankton model if rare (95% of values in a region are less than the across site mean, or more than 10% of values in a region are zeros).
sside and cent have no data in FW and W.
marfish and clams excluded if 95% of values in a region are less than the across site mean, though this results in marfish being excluded from W.
FW: exclude clad, mysid, corbic, sside/cent
W: exclude clad, corbic, marfish, sside/cent
N: exclude clad, potam, marfish
S: exclude mysid, potam, marfish
dataavail=focaldata %>%
gather(var, value, 4:length(fvars)) %>%
group_by(var) %>%
mutate(varmean=mean(value, na.rm=T)) %>% ungroup() %>%
group_by(region, var) %>%
summarize(
propmissing=length(which(is.na(value)))/length(value),
propzeros=length(which(value==0))/length(which(!is.na(value))),
exclude=ifelse(quantile(value,probs = 0.95, na.rm = T)<mean(varmean),T,F)) %>%
as.data.frame()
#these variables should not be used (too many zeros)
filter(dataavail,propzeros>0.1 | exclude) %>% filter(var %in% c("mysid","hcope","pcope","rotif_m","clad"))
## region var propmissing propzeros exclude
## 1 Far West clad 0.141025641 0.95149254 TRUE
## 2 Far West mysid 0.137820513 0.21933086 TRUE
## 3 North clad 0.012820513 0.14610390 FALSE
## 4 South mysid 0.006410256 0.08709677 TRUE
## 5 West clad 0.009615385 0.26537217 FALSE
filter(dataavail,exclude) %>% filter(var %in% c("marfish_bsmt","potam","corbic"))
## region var propmissing propzeros exclude
## 1 Far West corbic 0.1410256 1.0000000 TRUE
## 2 North marfish_bsmt 0.1891026 0.9762846 TRUE
## 3 North potam 0.1378205 0.1486989 TRUE
## 4 South marfish_bsmt 0.1826923 1.0000000 TRUE
## 5 South potam 0.1378205 0.9702602 TRUE
## 6 West corbic 0.1378205 0.8066914 TRUE
## 7 West marfish_bsmt 0.1666667 0.2192308 TRUE
Breakdown of total zooplankton biomass.
## Warning: Removed 272 rows containing missing values (position_stack).
Correlation between biomass and energy.
for(i in 1:length(regions)) {
dtemp=filter(fdr,region==regions[i])
print(regions[i])
print(cor(dtemp$tzoop,dtemp$tzoop_e,use = "p"))
print(cor(dtemp$hzoop,dtemp$hzoop_e,use = "p"))
print(cor(dtemp$pzoop,dtemp$pzoop_e,use = "p"))
}
## [1] "Far West"
## [1] 0.9967037
## [1] 0.9969857
## [1] 0.9996106
## [1] "North"
## [1] 0.9958978
## [1] 0.9945197
## [1] 0.999494
## [1] "South"
## [1] 0.9967635
## [1] 0.9965366
## [1] 0.99925
## [1] "West"
## [1] 0.9964103
## [1] 0.994996
## [1] 0.9983814
(only sig correlations shown… no correction for multiple comparisons)
Other notes:
Detrended fish indices are NOT correlated in S!
Nitrate and ammonia are positively correlated, max at lag 0 all regions.
Nitrate and dophos are positively correlated, max at lag 0 all regions.
Ammonia and dophos are positively correlated, lag 0 for FW and S, ammonia lags dphos by 3 months in W and N.
Chla nitrate neg correlated, lag 0.
Chla ammonia neg correlated, lag 0.
Chla dophos relationship unclear.
High flow 2-4 month prev = high chla
Hcope lags chla by 1, positive, except FW.
Clad seem to precede chla by 2, positive.
Amphi relationship unclear, prob bc not eating chla in water column.
In N and W, chla lags potam, negative. The opposite in W.
Mysid and hcope postive, lag 0.
In S and W, hcope lags pcope, negative.
modFW='hzoop~hb1*chla_1+hs1*hzoop_1+ht1*pzoop_1+ht2*potam_1+ht3*estfish_bsmt_1+ha1*flow+ha2*temp+ha3*secchi
pzoop~pb1*hzoop_1+ps1*pzoop_1+pt1*potam_1+pt2*estfish_bsmt_1+pa1*flow+pa2*temp+pa3*secchi
estfish_bsmt~fb1*hzoop_1+fb2*pzoop_1+fs1*estfish_bsmt_1+fa1*flow+fa2*temp+fa3*secchi+ft1*marfish_bsmt_1
hb:=hb1
hs:=hs1
ht:=ht1+ht2+ht3
ha:=ha1-ha2-ha3
pb:=pb1
ps:=ps1
pt:=pt1+pt2
pa:=pa1-pa2-pa3
fb:=fb1+fb2
fs:=fs1
ft:=ft1
fa:=fa1-fa2-fa3
'
modW='hzoop~hb1*chla_1+hs1*hzoop_1+ht1*pzoop_1+ht2*potam_1+ht3*estfish_bsmt_1+ha1*flow+ha2*temp+ha3*secchi
pzoop~pb1*chla_1+pb2*hzoop_1+ps1*pzoop_1+pt1*potam_1+pt2*estfish_bsmt_1+pa1*flow+pa2*temp+pa3*secchi
estfish_bsmt~fb1*hzoop_1+fb2*pzoop_1+fs1*estfish_bsmt_1+fa1*flow+fa2*temp+fa3*secchi
hb:=hb1
hs:=hs1
ht:=ht1+ht2+ht3
ha:=ha1-ha2-ha3
pb:=pb1+pb2
ps:=ps1
pt:=pt1+pt2
pa:=pa1-pa2-pa3
fb:=fb1+fb2
fs:=fs1
fa:=fa1-fa2-fa3
'
modN='hzoop~hb1*chla_1+hs1*hzoop_1+ht1*pzoop_1+ht2*corbic_1+ht3*estfish_bsmt_1+ha1*flow+ha2*temp+ha3*secchi
pzoop~pb1*chla_1+pb2*hzoop_1+ps1*pzoop_1+pt1*corbic_1+pt2*estfish_bsmt_1+pa1*flow+pa2*temp+pa3*secchi
estfish_bsmt~fb1*hzoop_1+fb2*pzoop_1+fs1*estfish_bsmt_1+fa1*flow+fa2*temp+fa3*secchi+ft1*sside_1+ft2*cent_1
hb:=hb1
hs:=hs1
ht:=ht1+ht2+ht3
ha:=ha1-ha2-ha3
pb:=pb1+pb2
ps:=ps1
pt:=pt1+pt2
pa:=pa1-pa2-pa3
fb:=fb1+fb2
fs:=fs1
ft:=ft1+ft2
fa:=fa1-fa2-fa3
'
modS='hzoop~hb1*chla_1+hs1*hzoop_1+ht1*pzoop_1+ht2*corbic_1+ht3*estfish_bsmt_1+ha1*flow+ha2*temp+ha3*secchi
pzoop~pb1*chla_1+pb2*hzoop_1+ps1*pzoop_1+pt1*corbic_1+pt2*estfish_bsmt_1+pa1*flow+pa2*temp+pa3*secchi
estfish_bsmt~fb1*chla_1+fb2*hzoop_1+fb3*pzoop_1+fs1*estfish_bsmt_1+fa1*flow+fa2*temp+fa3*secchi+ft1*sside_1+ft2*cent_1
hb:=hb1
hs:=hs1
ht:=ht1+ht2+ht3
ha:=ha1-ha2-ha3
pb:=pb1+pb2
ps:=ps1
pt:=pt1+pt2
pa:=pa1-pa2-pa3
fb:=fb1+fb2+fb3
fs:=fs1
ft:=ft1+ft2
fa:=fa1-fa2-fa3
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 26 iterations
##
## Optimization method NLMINB
## Number of free parameters 28
##
## Used Total
## Number of observations 191 312
##
## Estimator ML
## Model Fit Test Statistic 6.605
## Degrees of freedom 5
## P-value (Chi-square) 0.252
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## hzoop ~
## chla_1 (hb1) 0.032 0.081 0.392 0.695 0.032 0.025
## hzoop_1 (hs1) 0.316 0.065 4.863 0.000 0.316 0.327
## pzoop_1 (ht1) 0.060 0.069 0.871 0.384 0.060 0.057
## potam_1 (ht2) -0.181 0.056 -3.214 0.001 -0.181 -0.210
## estfs__1 (ht3) -0.175 0.070 -2.519 0.012 -0.175 -0.172
## flow (ha1) -0.019 0.080 -0.235 0.815 -0.019 -0.016
## temp (ha2) -0.248 0.199 -1.247 0.212 -0.248 -0.085
## secchi (ha3) -0.045 0.082 -0.548 0.584 -0.045 -0.039
## pzoop ~
## hzoop_1 (pb1) 0.045 0.060 0.744 0.457 0.045 0.049
## pzoop_1 (ps1) 0.340 0.064 5.295 0.000 0.340 0.344
## potam_1 (pt1) -0.085 0.052 -1.640 0.101 -0.085 -0.105
## estfs__1 (pt2) -0.031 0.065 -0.475 0.635 -0.031 -0.032
## flow (pa1) 0.149 0.075 1.990 0.047 0.149 0.138
## temp (pa2) -0.050 0.186 -0.271 0.786 -0.050 -0.018
## secchi (pa3) -0.208 0.076 -2.718 0.007 -0.208 -0.193
## estfish_bsmt ~
## hzoop_1 (fb1) -0.181 0.055 -3.270 0.001 -0.181 -0.198
## pzoop_1 (fb2) 0.129 0.060 2.142 0.032 0.129 0.131
## estfs__1 (fs1) 0.341 0.060 5.668 0.000 0.341 0.353
## flow (fa1) 0.099 0.071 1.395 0.163 0.099 0.091
## temp (fa2) -0.092 0.175 -0.527 0.598 -0.092 -0.033
## secchi (fa3) -0.247 0.071 -3.475 0.001 -0.247 -0.228
## mrfsh__1 (ft1) 0.001 0.081 0.015 0.988 0.001 0.001
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hzoop ~~
## .pzoop -0.022 0.043 -0.508 0.612 -0.022 -0.037
## .estfish_bsmt -0.039 0.040 -0.971 0.331 -0.039 -0.070
## .pzoop ~~
## .estfish_bsmt -0.068 0.037 -1.805 0.071 -0.068 -0.132
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hzoop 0.630 0.064 9.772 0.000 0.630 0.755
## .pzoop 0.551 0.056 9.772 0.000 0.551 0.739
## .estfish_bsmt 0.477 0.049 9.772 0.000 0.477 0.639
##
## R-Square:
## Estimate
## hzoop 0.245
## pzoop 0.261
## estfish_bsmt 0.361
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## hb 0.032 0.081 0.392 0.695 0.032 0.025
## hs 0.316 0.065 4.863 0.000 0.316 0.327
## ht -0.296 0.109 -2.710 0.007 -0.296 -0.324
## ha 0.274 0.204 1.342 0.180 0.274 0.108
## pb 0.045 0.060 0.744 0.457 0.045 0.049
## ps 0.340 0.064 5.295 0.000 0.340 0.344
## pt -0.116 0.076 -1.521 0.128 -0.116 -0.137
## pa 0.408 0.191 2.133 0.033 0.408 0.348
## fb -0.052 0.078 -0.664 0.507 -0.052 -0.067
## fs 0.341 0.060 5.668 0.000 0.341 0.353
## ft 0.001 0.081 0.015 0.988 0.001 0.001
## fa 0.438 0.181 2.417 0.016 0.438 0.353
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 34 iterations
##
## Optimization method NLMINB
## Number of free parameters 28
##
## Used Total
## Number of observations 210 312
##
## Estimator ML
## Model Fit Test Statistic 0.042
## Degrees of freedom 2
## P-value (Chi-square) 0.979
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## hzoop ~
## chla_1 (hb1) 0.062 0.081 0.770 0.441 0.062 0.047
## hzoop_1 (hs1) 0.430 0.069 6.227 0.000 0.430 0.413
## pzoop_1 (ht1) 0.015 0.081 0.184 0.854 0.015 0.011
## potam_1 (ht2) -0.196 0.067 -2.914 0.004 -0.196 -0.182
## estfs__1 (ht3) 0.020 0.072 0.279 0.781 0.020 0.017
## flow (ha1) 0.251 0.074 3.370 0.001 0.251 0.203
## temp (ha2) 0.030 0.210 0.142 0.887 0.030 0.009
## secchi (ha3) 0.190 0.073 2.609 0.009 0.190 0.163
## pzoop ~
## chla_1 (pb1) 0.182 0.060 3.029 0.002 0.182 0.182
## hzoop_1 (pb2) 0.081 0.052 1.557 0.119 0.081 0.103
## pzoop_1 (ps1) 0.423 0.061 6.888 0.000 0.423 0.419
## potam_1 (pt1) -0.068 0.050 -1.361 0.174 -0.068 -0.084
## estfs__1 (pt2) 0.035 0.054 0.656 0.512 0.035 0.039
## flow (pa1) -0.093 0.056 -1.651 0.099 -0.093 -0.100
## temp (pa2) 0.501 0.158 3.168 0.002 0.501 0.190
## secchi (pa3) -0.023 0.055 -0.411 0.681 -0.023 -0.026
## estfish_bsmt ~
## hzoop_1 (fb1) 0.092 0.061 1.501 0.133 0.092 0.104
## pzoop_1 (fb2) -0.081 0.078 -1.044 0.296 -0.081 -0.071
## estfs__1 (fs1) 0.278 0.068 4.089 0.000 0.278 0.270
## flow (fa1) -0.212 0.071 -2.997 0.003 -0.212 -0.202
## temp (fa2) 0.111 0.198 0.561 0.575 0.111 0.037
## secchi (fa3) -0.227 0.067 -3.396 0.001 -0.227 -0.228
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hzoop ~~
## .pzoop 0.119 0.032 3.692 0.000 0.119 0.263
## .estfish_bsmt -0.054 0.040 -1.354 0.176 -0.054 -0.094
## .pzoop ~~
## .estfish_bsmt 0.073 0.030 2.412 0.016 0.073 0.169
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hzoop 0.600 0.059 10.247 0.000 0.600 0.666
## .pzoop 0.341 0.033 10.247 0.000 0.341 0.667
## .estfish_bsmt 0.549 0.054 10.247 0.000 0.549 0.835
##
## R-Square:
## Estimate
## hzoop 0.334
## pzoop 0.333
## estfish_bsmt 0.165
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## hb 0.062 0.081 0.770 0.441 0.062 0.047
## hs 0.430 0.069 6.227 0.000 0.430 0.413
## ht -0.161 0.122 -1.317 0.188 -0.161 -0.154
## ha 0.031 0.213 0.143 0.886 0.031 0.032
## pb 0.263 0.068 3.884 0.000 0.263 0.285
## ps 0.423 0.061 6.888 0.000 0.423 0.419
## pt -0.033 0.077 -0.426 0.670 -0.033 -0.045
## pa -0.571 0.160 -3.558 0.000 -0.571 -0.264
## fb 0.011 0.084 0.130 0.896 0.011 0.033
## fs 0.278 0.068 4.089 0.000 0.278 0.270
## fa -0.096 0.201 -0.477 0.634 -0.096 -0.011
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 34 iterations
##
## Optimization method NLMINB
## Number of free parameters 30
##
## Used Total
## Number of observations 193 312
##
## Estimator ML
## Model Fit Test Statistic 4.536
## Degrees of freedom 6
## P-value (Chi-square) 0.604
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## hzoop ~
## chla_1 (hb1) 0.026 0.074 0.353 0.724 0.026 0.023
## hzoop_1 (hs1) 0.200 0.069 2.899 0.004 0.200 0.195
## pzoop_1 (ht1) 0.040 0.086 0.466 0.641 0.040 0.033
## corbic_1 (ht2) 0.017 0.058 0.296 0.767 0.017 0.019
## estfs__1 (ht3) -0.070 0.088 -0.798 0.425 -0.070 -0.057
## flow (ha1) 0.323 0.076 4.275 0.000 0.323 0.309
## temp (ha2) 0.295 0.195 1.511 0.131 0.295 0.100
## secchi (ha3) -0.162 0.063 -2.574 0.010 -0.162 -0.172
## pzoop ~
## chla_1 (pb1) 0.218 0.058 3.747 0.000 0.218 0.235
## hzoop_1 (pb2) 0.111 0.054 2.043 0.041 0.111 0.132
## pzoop_1 (ps1) 0.283 0.068 4.163 0.000 0.283 0.279
## corbic_1 (pt1) 0.006 0.046 0.138 0.890 0.006 0.009
## estfs__1 (pt2) -0.032 0.069 -0.463 0.643 -0.032 -0.032
## flow (pa1) -0.238 0.059 -4.008 0.000 -0.238 -0.278
## temp (pa2) 0.319 0.153 2.079 0.038 0.319 0.132
## secchi (pa3) 0.007 0.050 0.147 0.883 0.007 0.009
## estfish_bsmt ~
## hzoop_1 (fb1) 0.113 0.056 2.025 0.043 0.113 0.135
## pzoop_1 (fb2) 0.040 0.068 0.593 0.553 0.040 0.040
## estfs__1 (fs1) 0.127 0.070 1.822 0.068 0.127 0.127
## flow (fa1) -0.388 0.060 -6.484 0.000 -0.388 -0.454
## temp (fa2) 0.069 0.153 0.455 0.649 0.069 0.029
## secchi (fa3) -0.073 0.050 -1.462 0.144 -0.073 -0.094
## sside_1 (ft1) -0.014 0.065 -0.214 0.831 -0.014 -0.014
## cent_1 (ft2) -0.107 0.049 -2.200 0.028 -0.107 -0.141
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hzoop ~~
## .pzoop 0.099 0.032 3.063 0.002 0.099 0.226
## .estfish_bsmt -0.016 0.032 -0.517 0.605 -0.016 -0.037
## .pzoop ~~
## .estfish_bsmt 0.022 0.025 0.900 0.368 0.022 0.065
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hzoop 0.560 0.057 9.823 0.000 0.560 0.787
## .pzoop 0.346 0.035 9.823 0.000 0.346 0.725
## .estfish_bsmt 0.344 0.035 9.823 0.000 0.344 0.722
##
## R-Square:
## Estimate
## hzoop 0.213
## pzoop 0.275
## estfish_bsmt 0.278
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## hb 0.026 0.074 0.353 0.724 0.026 0.023
## hs 0.200 0.069 2.899 0.004 0.200 0.195
## ht -0.013 0.123 -0.103 0.918 -0.013 -0.005
## ha 0.191 0.209 0.911 0.362 0.191 0.382
## pb 0.329 0.077 4.246 0.000 0.329 0.367
## ps 0.283 0.068 4.163 0.000 0.283 0.279
## pt -0.026 0.080 -0.322 0.747 -0.026 -0.023
## pa -0.564 0.164 -3.429 0.001 -0.564 -0.420
## fb 0.153 0.077 1.995 0.046 0.153 0.175
## fs 0.127 0.070 1.822 0.068 0.127 0.127
## ft -0.121 0.080 -1.521 0.128 -0.121 -0.155
## fa -0.385 0.167 -2.313 0.021 -0.385 -0.389
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 37 iterations
##
## Optimization method NLMINB
## Number of free parameters 31
##
## Used Total
## Number of observations 199 312
##
## Estimator ML
## Model Fit Test Statistic 5.034
## Degrees of freedom 5
## P-value (Chi-square) 0.412
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## hzoop ~
## chla_1 (hb1) 0.182 0.055 3.301 0.001 0.182 0.225
## hzoop_1 (hs1) 0.215 0.070 3.057 0.002 0.215 0.205
## pzoop_1 (ht1) -0.021 0.065 -0.322 0.748 -0.021 -0.023
## corbic_1 (ht2) 0.061 0.047 1.311 0.190 0.061 0.087
## estfs__1 (ht3) -0.011 0.062 -0.174 0.862 -0.011 -0.012
## flow (ha1) 0.103 0.056 1.834 0.067 0.103 0.122
## temp (ha2) 0.469 0.178 2.636 0.008 0.469 0.177
## secchi (ha3) 0.027 0.051 0.540 0.589 0.027 0.036
## pzoop ~
## chla_1 (pb1) 0.269 0.054 4.964 0.000 0.269 0.302
## hzoop_1 (pb2) 0.161 0.069 2.320 0.020 0.161 0.139
## pzoop_1 (ps1) 0.328 0.064 5.116 0.000 0.328 0.324
## corbic_1 (pt1) -0.051 0.045 -1.134 0.257 -0.051 -0.066
## estfs__1 (pt2) 0.030 0.061 0.490 0.624 0.030 0.030
## flow (pa1) -0.090 0.055 -1.627 0.104 -0.090 -0.097
## temp (pa2) -0.130 0.175 -0.740 0.459 -0.130 -0.044
## secchi (pa3) -0.081 0.050 -1.610 0.107 -0.081 -0.096
## estfish_bsmt ~
## chla_1 (fb1) 0.119 0.059 2.000 0.045 0.119 0.135
## hzoop_1 (fb2) 0.164 0.076 2.166 0.030 0.164 0.143
## pzoop_1 (fb3) -0.041 0.070 -0.575 0.565 -0.041 -0.041
## estfs__1 (fs1) 0.212 0.067 3.158 0.002 0.212 0.217
## flow (fa1) -0.031 0.060 -0.510 0.610 -0.031 -0.034
## temp (fa2) -0.098 0.192 -0.511 0.609 -0.098 -0.034
## secchi (fa3) -0.181 0.057 -3.164 0.002 -0.181 -0.219
## sside_1 (ft1) 0.060 0.071 0.846 0.398 0.060 0.055
## cent_1 (ft2) -0.064 0.055 -1.166 0.244 -0.064 -0.081
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hzoop ~~
## .pzoop 0.048 0.025 1.899 0.058 0.048 0.136
## .estfish_bsmt 0.014 0.027 0.515 0.606 0.014 0.037
## .pzoop ~~
## .estfish_bsmt 0.076 0.028 2.767 0.006 0.076 0.200
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .hzoop 0.360 0.036 9.975 0.000 0.360 0.843
## .pzoop 0.349 0.035 9.975 0.000 0.349 0.670
## .estfish_bsmt 0.417 0.042 9.975 0.000 0.417 0.824
##
## R-Square:
## Estimate
## hzoop 0.157
## pzoop 0.330
## estfish_bsmt 0.176
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## hb 0.182 0.055 3.301 0.001 0.182 0.225
## hs 0.215 0.070 3.057 0.002 0.215 0.205
## ht 0.030 0.092 0.321 0.748 0.030 0.052
## ha -0.394 0.185 -2.133 0.033 -0.394 -0.091
## pb 0.430 0.083 5.157 0.000 0.430 0.441
## ps 0.328 0.064 5.116 0.000 0.328 0.324
## pt -0.021 0.078 -0.274 0.784 -0.021 -0.036
## pa 0.121 0.182 0.664 0.507 0.121 0.044
## fb 0.242 0.099 2.446 0.014 0.242 0.238
## fs 0.212 0.067 3.158 0.002 0.212 0.217
## ft -0.004 0.098 -0.043 0.965 -0.004 -0.026
## fa 0.248 0.200 1.240 0.215 0.248 0.219
#modificationindices(modfitW, sort=T, maximum.number=20)
#residuals(modfitS)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
Total effects
Abiotic:
positive values = promoted by high flow, low temp, low secchi/high turbidity
negative values = promoted by low flow, high temp, high secchi/low turbidity
ssFW=standardizedsolution(modfitFW) %>% mutate(region="Far West")
ssW=standardizedsolution(modfitW) %>% mutate(region="West")
ssN=standardizedsolution(modfitN) %>% mutate(region="North")
ssS=standardizedsolution(modfitS) %>% mutate(region="South")
ssut=rbind(ssFW,ssW,ssN,ssS) %>% filter(op==":=") %>% select(region,lhs,est.std:ci.upper) %>%
separate(lhs,c("variable","influence"), sep=1) %>%
mutate(variable=case_when(variable=="h" ~ "herbivorous\nzooplankton",
variable=="p" ~ "predatory\nzooplankton",
variable=="f" ~ "estuarine\nfishes"),
influence=case_when(influence=="b" ~ "bottom-up",
influence=="t" ~ "top-down",
influence=="s" ~ "self-regulation",
influence=="a" ~ "abiotic drivers"),
region=factor(region, levels=regionorder),
influence=factor(influence, levels=c("self-regulation","bottom-up","top-down","abiotic drivers")),
variable=factor(variable,levels=c("estuarine\nfishes","predatory\nzooplankton","herbivorous\nzooplankton")),
sig=ifelse(pvalue<0.05,"*",""))
ggplot(ssut,aes(x=influence,y=est.std)) +
facet_grid(variable~region) +
geom_errorbar(aes(ymin=ci.lower, ymax=ci.upper),width=0.5) +
geom_point() +
geom_text(aes(y=ci.upper+0.05, label=sig)) +
geom_hline(yintercept = 0) +
theme_bw() + theme(axis.text.x=element_text(angle=90, vjust=0.5, hjust=1)) +
labs(y="total effect (standardized)")
#ggsave("../uteffects.png",width = 6,height=5)
modFW='din~ns1*din_1+nt1*chla_1+nn1*hzoop_1+nn2*pzoop_1+nn3*potam_1+na1*flow+na2*temp+na3*secchi
chla~cb1*din+cs1*chla_1+ct1*hzoop_1+ct2*potam_1+ca1*flow+ca2*temp+ca3*secchi
potam~lb1*chla_1+lb2*hzoop_1+lb3*pzoop_1+ls1*potam_1+la1*flow+la2*temp+la3*secchi
ns:=ns1
nt:=nt1
nn:=nn1+nn2+nn3
na:=na1-na2-na3
cb:=cb1
cs:=cs1
ct:=ct1+ct2
ca:=ca1-ca2-ca3
lb:=lb1+lb2+lb3
ls:=ls1
la:=la1-la2-la3
'
modW='din~ns1*din_1+nt1*chla_1+nn1*hzoop_1+nn2*pzoop_1+nn3*potam_1+na1*flow+na2*temp+na3*secchi
chla~cb1*din+cs1*chla_1+ct1*hzoop_1+ct2*potam_1+ca1*flow+ca2*temp+ca3*secchi
potam~lb1*din_1+lb2*chla_1+lb3*hzoop_1+lb4*pzoop_1+ls1*potam_1+la1*flow+la2*temp+la3*secchi
ns:=ns1
nt:=nt1
nn:=nn1+nn2+nn3
na:=na1-na2-na3
cb:=cb1
cs:=cs1
ct:=ct1+ct2
ca:=ca1-ca2-ca3
lb:=lb1+lb2+lb3+lb4
ls:=ls1
la:=la1-la2-la3'
modN='din~ns1*din_1+nt1*chla_1+nn1*hzoop_1+nn2*pzoop_1+nn3*corbic_1+na1*flow+na2*temp+na3*secchi
chla~cb1*din+cs1*chla_1+ct1*hzoop_1+ct2*corbic_1+ca1*flow+ca2*temp+ca3*secchi
corbic~lb1*chla_1+lb2*hzoop_1+lb3*pzoop_1+ls1*corbic_1+la1*flow+la2*temp+la3*secchi
ns:=ns1
nt:=nt1
nn:=nn1+nn2+nn3
na:=na1-na2-na3
cb:=cb1
cs:=cs1
ct:=ct1+ct2
ca:=ca1-ca2-ca3
lb:=lb1+lb2+lb3
ls:=ls1
la:=la1-la2-la3'
modS='din~ns1*din_1+nt1*chla_1+nn1*hzoop_1+nn2*pzoop_1+nn3*corbic_1+na1*flow+na2*temp+na3*secchi
chla~cb1*din+cs1*chla_1+ct1*hzoop_1+ct2*corbic_1+ca1*flow+ca2*temp+ca3*secchi
corbic~lb1*chla_1+lb2*hzoop_1+lb3*pzoop_1+ls1*corbic_1+la1*flow+la2*temp+la3*secchi
ns:=ns1
nt:=nt1
nn:=nn1+nn2+nn3
na:=na1-na2-na3
cb:=cb1
cs:=cs1
ct:=ct1+ct2
ca:=ca1-ca2-ca3
lb:=lb1+lb2+lb3
ls:=ls1
la:=la1-la2-la3'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 26 iterations
##
## Optimization method NLMINB
## Number of free parameters 26
##
## Used Total
## Number of observations 234 312
##
## Estimator ML
## Model Fit Test Statistic 3.232
## Degrees of freedom 4
## P-value (Chi-square) 0.520
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## din ~
## din_1 (ns1) 0.428 0.059 7.282 0.000 0.428 0.428
## chla_1 (nt1) -0.008 0.081 -0.095 0.924 -0.008 -0.006
## hzoop_1 (nn1) 0.031 0.063 0.494 0.621 0.031 0.030
## pzoop_1 (nn2) -0.015 0.068 -0.217 0.828 -0.015 -0.013
## potam_1 (nn3) -0.003 0.058 -0.060 0.952 -0.003 -0.004
## flow (na1) -0.043 0.079 -0.544 0.587 -0.043 -0.034
## temp (na2) -0.495 0.187 -2.656 0.008 -0.495 -0.164
## secchi (na3) 0.133 0.074 1.802 0.071 0.133 0.117
## chla ~
## din (cb1) -0.091 0.046 -1.990 0.047 -0.091 -0.127
## chla_1 (cs1) 0.246 0.062 3.979 0.000 0.246 0.250
## hzoop_1 (ct1) -0.004 0.049 -0.090 0.928 -0.004 -0.006
## potam_1 (ct2) -0.017 0.045 -0.390 0.697 -0.017 -0.025
## flow (ca1) 0.000 0.061 0.003 0.998 0.000 0.000
## temp (ca2) 0.252 0.146 1.734 0.083 0.252 0.117
## secchi (ca3) 0.041 0.057 0.713 0.476 0.041 0.050
## potam ~
## chla_1 (lb1) 0.074 0.067 1.100 0.271 0.074 0.053
## hzoop_1 (lb2) -0.086 0.053 -1.623 0.105 -0.086 -0.081
## pzoop_1 (lb3) -0.169 0.057 -2.961 0.003 -0.169 -0.146
## potam_1 (ls1) 0.633 0.049 13.016 0.000 0.633 0.633
## flow (la1) 0.052 0.067 0.781 0.435 0.052 0.041
## temp (la2) -0.139 0.156 -0.888 0.374 -0.139 -0.045
## secchi (la3) -0.063 0.062 -1.008 0.314 -0.063 -0.054
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .potam 0.017 0.030 0.578 0.564 0.017 0.038
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din 0.707 0.065 10.817 0.000 0.707 0.769
## .chla 0.422 0.039 10.817 0.000 0.422 0.898
## .potam 0.502 0.046 10.817 0.000 0.502 0.524
##
## R-Square:
## Estimate
## din 0.231
## chla 0.102
## potam 0.476
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ns 0.428 0.059 7.282 0.000 0.428 0.428
## nt -0.008 0.081 -0.095 0.924 -0.008 -0.006
## nn 0.013 0.113 0.117 0.907 0.013 0.013
## na 0.319 0.186 1.719 0.086 0.319 0.013
## cb -0.091 0.046 -1.990 0.047 -0.091 -0.127
## cs 0.246 0.062 3.979 0.000 0.246 0.250
## ct -0.022 0.073 -0.300 0.764 -0.022 -0.031
## ca -0.293 0.142 -2.068 0.039 -0.293 -0.167
## lb -0.182 0.097 -1.869 0.062 -0.182 -0.174
## ls 0.633 0.049 13.016 0.000 0.633 0.633
## la 0.253 0.156 1.624 0.104 0.253 0.140
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 30 iterations
##
## Optimization method NLMINB
## Number of free parameters 27
##
## Used Total
## Number of observations 257 312
##
## Estimator ML
## Model Fit Test Statistic 7.202
## Degrees of freedom 3
## P-value (Chi-square) 0.066
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## din ~
## din_1 (ns1) 0.467 0.053 8.812 0.000 0.467 0.466
## chla_1 (nt1) -0.061 0.066 -0.923 0.356 -0.061 -0.047
## hzoop_1 (nn1) -0.032 0.051 -0.634 0.526 -0.032 -0.034
## pzoop_1 (nn2) 0.099 0.062 1.593 0.111 0.099 0.080
## potam_1 (nn3) 0.096 0.053 1.819 0.069 0.096 0.099
## flow (na1) -0.325 0.055 -5.851 0.000 -0.325 -0.292
## temp (na2) 0.087 0.161 0.539 0.590 0.087 0.026
## secchi (na3) -0.099 0.054 -1.828 0.068 -0.099 -0.094
## chla ~
## din (cb1) -0.179 0.053 -3.381 0.001 -0.179 -0.230
## chla_1 (cs1) 0.146 0.063 2.323 0.020 0.146 0.146
## hzoop_1 (ct1) 0.080 0.048 1.677 0.094 0.080 0.109
## potam_1 (ct2) 0.036 0.051 0.721 0.471 0.036 0.049
## flow (ca1) 0.005 0.057 0.096 0.924 0.005 0.006
## temp (ca2) -0.147 0.156 -0.940 0.347 -0.147 -0.057
## secchi (ca3) 0.011 0.053 0.200 0.841 0.011 0.013
## potam ~
## din_1 (lb1) 0.094 0.044 2.139 0.032 0.094 0.090
## chla_1 (lb2) -0.012 0.055 -0.213 0.832 -0.012 -0.009
## hzoop_1 (lb3) -0.045 0.043 -1.061 0.289 -0.045 -0.046
## pzoop_1 (lb4) 0.117 0.051 2.279 0.023 0.117 0.091
## potam_1 (ls1) 0.711 0.044 16.161 0.000 0.711 0.705
## flow (la1) -0.074 0.046 -1.604 0.109 -0.074 -0.064
## temp (la2) -0.041 0.135 -0.303 0.762 -0.041 -0.012
## secchi (la3) 0.094 0.045 2.089 0.037 0.094 0.086
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .potam 0.028 0.022 1.266 0.205 0.028 0.079
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din 0.438 0.039 11.336 0.000 0.438 0.555
## .chla 0.416 0.037 11.336 0.000 0.416 0.875
## .potam 0.305 0.027 11.336 0.000 0.305 0.354
##
## R-Square:
## Estimate
## din 0.445
## chla 0.125
## potam 0.646
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ns 0.467 0.053 8.812 0.000 0.467 0.466
## nt -0.061 0.066 -0.923 0.356 -0.061 -0.047
## nn 0.162 0.094 1.723 0.085 0.162 0.145
## na -0.313 0.163 -1.918 0.055 -0.313 -0.224
## cb -0.179 0.053 -3.381 0.001 -0.179 -0.230
## cs 0.146 0.063 2.323 0.020 0.146 0.146
## ct 0.116 0.077 1.500 0.134 0.116 0.157
## ca 0.142 0.158 0.894 0.371 0.142 0.051
## lb 0.155 0.087 1.767 0.077 0.155 0.127
## ls 0.711 0.044 16.161 0.000 0.711 0.705
## la -0.127 0.136 -0.936 0.349 -0.127 -0.138
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 25 iterations
##
## Optimization method NLMINB
## Number of free parameters 26
##
## Used Total
## Number of observations 255 312
##
## Estimator ML
## Model Fit Test Statistic 7.281
## Degrees of freedom 4
## P-value (Chi-square) 0.122
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## din ~
## din_1 (ns1) 0.167 0.056 3.002 0.003 0.167 0.169
## chla_1 (nt1) -0.121 0.054 -2.245 0.025 -0.121 -0.118
## hzoop_1 (nn1) 0.032 0.054 0.605 0.545 0.032 0.032
## pzoop_1 (nn2) 0.304 0.068 4.464 0.000 0.304 0.247
## corbic_1 (nn3) -0.052 0.046 -1.114 0.265 -0.052 -0.059
## flow (na1) -0.389 0.058 -6.665 0.000 -0.389 -0.369
## temp (na2) 0.081 0.160 0.506 0.613 0.081 0.027
## secchi (na3) -0.042 0.047 -0.906 0.365 -0.042 -0.047
## chla ~
## din (cb1) -0.208 0.065 -3.202 0.001 -0.208 -0.214
## chla_1 (cs1) 0.233 0.059 3.960 0.000 0.233 0.235
## hzoop_1 (ct1) -0.074 0.058 -1.277 0.202 -0.074 -0.076
## corbic_1 (ct2) 0.005 0.051 0.094 0.925 0.005 0.006
## flow (ca1) -0.104 0.070 -1.489 0.137 -0.104 -0.101
## temp (ca2) 0.404 0.177 2.290 0.022 0.404 0.138
## secchi (ca3) -0.077 0.052 -1.486 0.137 -0.077 -0.088
## corbic ~
## chla_1 (lb1) 0.008 0.064 0.132 0.895 0.008 0.007
## hzoop_1 (lb2) 0.042 0.065 0.644 0.520 0.042 0.036
## pzoop_1 (lb3) -0.058 0.081 -0.720 0.472 -0.058 -0.041
## corbic_1 (ls1) 0.464 0.056 8.272 0.000 0.464 0.461
## flow (la1) 0.017 0.070 0.239 0.811 0.017 0.014
## temp (la2) -0.158 0.194 -0.817 0.414 -0.158 -0.046
## secchi (la3) 0.118 0.057 2.083 0.037 0.118 0.115
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .corbic -0.054 0.040 -1.356 0.175 -0.054 -0.085
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din 0.469 0.042 11.292 0.000 0.469 0.666
## .chla 0.581 0.051 11.292 0.000 0.581 0.868
## .corbic 0.694 0.061 11.292 0.000 0.694 0.746
##
## R-Square:
## Estimate
## din 0.334
## chla 0.132
## corbic 0.254
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ns 0.167 0.056 3.002 0.003 0.167 0.169
## nt -0.121 0.054 -2.245 0.025 -0.121 -0.118
## nn 0.285 0.094 3.044 0.002 0.285 0.221
## na -0.428 0.168 -2.547 0.011 -0.428 -0.348
## cb -0.208 0.065 -3.202 0.001 -0.208 -0.214
## cs 0.233 0.059 3.960 0.000 0.233 0.235
## ct -0.070 0.078 -0.899 0.369 -0.070 -0.070
## ca -0.431 0.188 -2.299 0.021 -0.431 -0.150
## lb -0.008 0.110 -0.073 0.941 -0.008 0.002
## ls 0.464 0.056 8.272 0.000 0.464 0.461
## la 0.057 0.203 0.282 0.778 0.057 -0.055
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 29 iterations
##
## Optimization method NLMINB
## Number of free parameters 26
##
## Used Total
## Number of observations 256 312
##
## Estimator ML
## Model Fit Test Statistic 3.118
## Degrees of freedom 4
## P-value (Chi-square) 0.538
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## din ~
## din_1 (ns1) 0.202 0.061 3.280 0.001 0.202 0.202
## chla_1 (nt1) 0.040 0.045 0.882 0.378 0.040 0.053
## hzoop_1 (nn1) -0.020 0.064 -0.309 0.757 -0.020 -0.019
## pzoop_1 (nn2) 0.009 0.054 0.175 0.861 0.009 0.011
## corbic_1 (nn3) 0.050 0.039 1.295 0.195 0.050 0.076
## flow (na1) -0.059 0.046 -1.283 0.200 -0.059 -0.076
## temp (na2) 0.229 0.154 1.483 0.138 0.229 0.087
## secchi (na3) -0.188 0.046 -4.082 0.000 -0.188 -0.255
## chla ~
## din (cb1) -0.006 0.083 -0.067 0.946 -0.006 -0.004
## chla_1 (cs1) 0.285 0.060 4.716 0.000 0.285 0.285
## hzoop_1 (ct1) 0.094 0.084 1.120 0.263 0.094 0.067
## corbic_1 (ct2) 0.069 0.052 1.325 0.185 0.069 0.080
## flow (ca1) -0.145 0.062 -2.317 0.021 -0.145 -0.139
## temp (ca2) 0.031 0.208 0.147 0.883 0.031 0.009
## secchi (ca3) -0.023 0.062 -0.370 0.711 -0.023 -0.024
## corbic ~
## chla_1 (lb1) 0.054 0.068 0.803 0.422 0.054 0.047
## hzoop_1 (lb2) -0.038 0.093 -0.412 0.681 -0.038 -0.024
## pzoop_1 (lb3) -0.052 0.081 -0.649 0.516 -0.052 -0.038
## corbic_1 (ls1) 0.322 0.057 5.601 0.000 0.322 0.325
## flow (la1) 0.082 0.068 1.191 0.234 0.082 0.069
## temp (la2) -0.287 0.231 -1.244 0.213 -0.287 -0.072
## secchi (la3) -0.205 0.065 -3.139 0.002 -0.205 -0.183
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .corbic -0.030 0.044 -0.674 0.500 -0.030 -0.042
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .din 0.347 0.031 11.314 0.000 0.347 0.835
## .chla 0.642 0.057 11.314 0.000 0.642 0.875
## .corbic 0.777 0.069 11.314 0.000 0.777 0.810
##
## R-Square:
## Estimate
## din 0.165
## chla 0.125
## corbic 0.190
##
## Defined Parameters:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## ns 0.202 0.061 3.280 0.001 0.202 0.202
## nt 0.040 0.045 0.882 0.378 0.040 0.053
## nn 0.040 0.084 0.473 0.636 0.040 0.068
## na -0.100 0.160 -0.624 0.533 -0.100 0.093
## cb -0.006 0.083 -0.067 0.946 -0.006 -0.004
## cs 0.285 0.060 4.716 0.000 0.285 0.285
## ct 0.163 0.095 1.719 0.086 0.163 0.147
## ca -0.152 0.214 -0.710 0.478 -0.152 -0.124
## lb -0.037 0.116 -0.316 0.752 -0.037 -0.015
## ls 0.322 0.057 5.601 0.000 0.322 0.325
## la 0.573 0.238 2.406 0.016 0.573 0.324
#modificationindices(modfitW, sort=T, maximum.number=20)
#residuals(modfitW)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
Total effects
Abiotic:
positive values = promoted by high flow, low temp, low secchi/high turbidity
negative values = promoted by low flow, high temp, high secchi/low turbidity
ssFW=standardizedsolution(modfitFW) %>% mutate(region="Far West")
ssW=standardizedsolution(modfitW) %>% mutate(region="West")
ssN=standardizedsolution(modfitN) %>% mutate(region="North")
ssS=standardizedsolution(modfitS) %>% mutate(region="South")
sslt=rbind(ssFW,ssW,ssN,ssS) %>% filter(op==":=") %>% select(region,lhs,est.std:ci.upper) %>%
separate(lhs,c("variable","influence"), sep=1) %>%
mutate(variable=case_when(variable=="n" ~ "DIN",
variable=="c" ~ "phytoplankton",
variable=="l" ~ "clams"),
influence=case_when(influence=="b" ~ "bottom-up",
influence=="t" ~ "top-down",
influence=="s" ~ "self-regulation",
influence=="a" ~ "abiotic drivers",
influence=="n" ~ "nutrient cycling"),
region=factor(region, levels=regionorder),
influence=factor(influence, levels=c("self-regulation","bottom-up","top-down","abiotic drivers","nutrient cycling")),
variable=factor(variable,levels=c("clams","phytoplankton","DIN")),
sig=ifelse(pvalue<0.05,"*",""))
ggplot(sslt,aes(x=influence,y=est.std)) +
facet_grid(variable~region) +
geom_errorbar(aes(ymin=ci.lower, ymax=ci.upper),width=0.5) +
geom_point() +
geom_text(aes(y=ci.upper+0.05, label=sig)) +
geom_hline(yintercept = 0) +
theme_bw() + theme(axis.text.x=element_text(angle=90, vjust=0.5, hjust=1)) +
labs(y="total effect (standardized)")
#ggsave("../lteffects.png",width = 6,height=5)
modFW='chla~chla_1+hcope_1+amphi_1+potam_1+flow+secchi+temp
hcope~chla_1+hcope_1+pcope_1+potam_1+flow+secchi+temp+estfish_bsmt_1
amphi~chla_1+amphi_1+flow+secchi+temp+estfish_bsmt_1
pcope~hcope_1+pcope_1+potam_1+flow+secchi+temp+estfish_bsmt_1
'
modW='chla~chla_1+hcope_1+amphi_1+potam_1+flow+secchi+temp+mysid_1
hcope~chla_1+hcope_1+pcope_1+mysid_1+potam_1+flow+secchi+temp+estfish_bsmt_1
amphi~chla_1+amphi_1+mysid_1+flow+secchi+temp+estfish_bsmt_1
pcope~hcope_1+pcope_1+mysid_1+potam_1+flow+secchi+temp+estfish_bsmt_1
mysid~chla_1+hcope_1+pcope_1+amphi_1+mysid_1+flow+secchi+temp+estfish_bsmt_1
'
modN='chla~chla_1+hcope_1+amphi_1+corbic_1+flow+secchi+temp
hcope~chla_1+hcope_1+pcope_1+mysid_1+corbic_1+flow+secchi+temp+estfish_bsmt_1
amphi~chla_1+amphi_1+flow+secchi+temp+estfish_bsmt_1
pcope~hcope_1+pcope_1+mysid_1+corbic_1+flow+secchi+temp+estfish_bsmt_1
mysid~hcope_1+pcope_1+mysid_1+amphi_1+flow+secchi+temp+estfish_bsmt_1
'
modS='chla~chla_1+hcope_1+clad_1+corbic_1+flow+secchi+temp
hcope~chla_1+hcope_1+pcope_1+corbic_1+flow+secchi+temp+estfish_bsmt_1
clad~chla_1+clad_1+pcope_1+flow+secchi+temp+estfish_bsmt_1
amphi~chla_1+amphi_1+flow+secchi+temp+estfish_bsmt_1
pcope~chla_1+hcope_1+clad_1+pcope_1+corbic_1+flow+secchi+temp+estfish_bsmt_1
'
modfitFW=sem(modFW, data=filter(fdr_ds,region=="Far West"))
modfitW=sem(modW, data=filter(fdr_ds,region=="West"))
modfitN=sem(modN, data=filter(fdr_ds,region=="North"))
modfitS=sem(modS, data=filter(fdr_ds,region=="South"))
summary(modfitFW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 42 iterations
##
## Optimization method NLMINB
## Number of free parameters 38
##
## Used Total
## Number of observations 203 312
##
## Estimator ML
## Model Fit Test Statistic 6.314
## Degrees of freedom 8
## P-value (Chi-square) 0.612
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.228 0.067 3.377 0.001 0.228 0.229
## hcope_1 0.058 0.048 1.212 0.226 0.058 0.083
## amphi_1 0.039 0.054 0.716 0.474 0.039 0.053
## potam_1 -0.001 0.045 -0.018 0.985 -0.001 -0.001
## flow 0.019 0.067 0.285 0.776 0.019 0.022
## secchi 0.023 0.064 0.359 0.720 0.023 0.028
## temp 0.279 0.153 1.819 0.069 0.279 0.128
## hcope ~
## chla_1 0.121 0.091 1.324 0.185 0.121 0.085
## hcope_1 0.240 0.068 3.505 0.000 0.240 0.240
## pcope_1 0.109 0.095 1.142 0.253 0.109 0.078
## potam_1 -0.149 0.063 -2.349 0.019 -0.149 -0.157
## flow -0.077 0.091 -0.853 0.393 -0.077 -0.062
## secchi 0.034 0.087 0.393 0.694 0.034 0.029
## temp -0.175 0.215 -0.816 0.414 -0.175 -0.056
## estfish_bsmt_1 -0.138 0.078 -1.774 0.076 -0.138 -0.127
## amphi ~
## chla_1 0.041 0.045 0.908 0.364 0.041 0.030
## amphi_1 0.790 0.036 21.755 0.000 0.790 0.795
## flow -0.236 0.045 -5.261 0.000 -0.236 -0.199
## secchi -0.000 0.043 -0.001 0.999 -0.000 -0.000
## temp 0.052 0.103 0.510 0.610 0.052 0.018
## estfish_bsmt_1 0.031 0.037 0.861 0.389 0.031 0.030
## pcope ~
## hcope_1 0.021 0.047 0.441 0.659 0.021 0.029
## pcope_1 0.277 0.066 4.209 0.000 0.277 0.280
## potam_1 -0.065 0.044 -1.494 0.135 -0.065 -0.097
## flow 0.202 0.062 3.237 0.001 0.202 0.231
## secchi -0.044 0.060 -0.737 0.461 -0.044 -0.053
## temp 0.329 0.148 2.219 0.026 0.329 0.150
## estfish_bsmt_1 0.002 0.054 0.033 0.973 0.002 0.002
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .hcope 0.025 0.042 0.606 0.545 0.025 0.043
## .amphi -0.001 0.020 -0.047 0.962 -0.001 -0.003
## .pcope 0.004 0.029 0.127 0.899 0.004 0.009
## .hcope ~~
## .amphi 0.009 0.028 0.343 0.731 0.009 0.024
## .pcope -0.109 0.040 -2.723 0.006 -0.109 -0.195
## .amphi ~~
## .pcope 0.007 0.019 0.384 0.701 0.007 0.027
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.429 0.043 10.075 0.000 0.429 0.908
## .hcope 0.814 0.081 10.075 0.000 0.814 0.849
## .amphi 0.190 0.019 10.075 0.000 0.190 0.216
## .pcope 0.388 0.039 10.075 0.000 0.388 0.810
##
## R-Square:
## Estimate
## chla 0.092
## hcope 0.151
## amphi 0.784
## pcope 0.190
summary(modfitW, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 52 iterations
##
## Optimization method NLMINB
## Number of free parameters 56
##
## Used Total
## Number of observations 215 312
##
## Estimator ML
## Model Fit Test Statistic 12.401
## Degrees of freedom 9
## P-value (Chi-square) 0.192
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.175 0.066 2.645 0.008 0.175 0.178
## hcope_1 0.041 0.058 0.699 0.484 0.041 0.050
## amphi_1 0.129 0.048 2.665 0.008 0.129 0.189
## potam_1 -0.061 0.055 -1.106 0.269 -0.061 -0.081
## flow 0.116 0.060 1.918 0.055 0.116 0.129
## secchi -0.050 0.061 -0.823 0.410 -0.050 -0.060
## temp -0.291 0.170 -1.709 0.087 -0.291 -0.113
## mysid_1 -0.126 0.062 -2.018 0.044 -0.126 -0.144
## hcope ~
## chla_1 0.107 0.076 1.418 0.156 0.107 0.089
## hcope_1 0.276 0.068 4.038 0.000 0.276 0.277
## pcope_1 -0.055 0.071 -0.782 0.434 -0.055 -0.049
## mysid_1 0.040 0.075 0.529 0.597 0.040 0.037
## potam_1 -0.184 0.061 -3.031 0.002 -0.184 -0.202
## flow -0.227 0.072 -3.158 0.002 -0.227 -0.207
## secchi 0.129 0.071 1.809 0.071 0.129 0.127
## temp 0.147 0.200 0.735 0.462 0.147 0.047
## estfish_bsmt_1 0.031 0.064 0.480 0.631 0.031 0.030
## amphi ~
## chla_1 -0.075 0.049 -1.522 0.128 -0.075 -0.053
## amphi_1 0.789 0.037 21.134 0.000 0.789 0.797
## mysid_1 0.118 0.046 2.575 0.010 0.118 0.093
## flow 0.013 0.046 0.275 0.783 0.013 0.010
## secchi 0.141 0.045 3.106 0.002 0.141 0.116
## temp -0.369 0.130 -2.827 0.005 -0.369 -0.098
## estfish_bsmt_1 -0.204 0.044 -4.668 0.000 -0.204 -0.167
## pcope ~
## hcope_1 -0.112 0.050 -2.236 0.025 -0.112 -0.132
## pcope_1 0.441 0.055 8.088 0.000 0.441 0.452
## mysid_1 0.114 0.057 2.002 0.045 0.114 0.124
## potam_1 0.009 0.047 0.185 0.853 0.009 0.011
## flow 0.158 0.054 2.944 0.003 0.158 0.169
## secchi 0.139 0.054 2.593 0.010 0.139 0.160
## temp 0.564 0.148 3.804 0.000 0.564 0.210
## estfish_bsmt_1 0.002 0.049 0.035 0.972 0.002 0.002
## mysid ~
## chla_1 0.187 0.063 2.969 0.003 0.187 0.167
## hcope_1 0.047 0.055 0.865 0.387 0.047 0.051
## pcope_1 0.143 0.059 2.397 0.017 0.143 0.134
## amphi_1 -0.110 0.046 -2.393 0.017 -0.110 -0.142
## mysid_1 0.370 0.061 6.033 0.000 0.370 0.371
## flow -0.236 0.058 -4.063 0.000 -0.236 -0.230
## secchi -0.246 0.058 -4.231 0.000 -0.246 -0.259
## temp 0.282 0.163 1.722 0.085 0.282 0.096
## estfish_bsmt_1 -0.027 0.054 -0.492 0.623 -0.027 -0.028
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .hcope 0.115 0.033 3.468 0.001 0.115 0.243
## .amphi -0.006 0.021 -0.292 0.770 -0.006 -0.020
## .pcope 0.008 0.024 0.330 0.741 0.008 0.023
## .mysid 0.052 0.027 1.976 0.048 0.052 0.136
## .hcope ~~
## .amphi -0.025 0.025 -0.994 0.320 -0.025 -0.068
## .pcope 0.072 0.029 2.472 0.013 0.072 0.171
## .mysid 0.117 0.032 3.682 0.000 0.117 0.259
## .amphi ~~
## .pcope 0.038 0.019 2.022 0.043 0.038 0.139
## .mysid -0.020 0.020 -0.996 0.319 -0.020 -0.068
## .pcope ~~
## .mysid 0.034 0.023 1.468 0.142 0.034 0.101
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.403 0.039 10.368 0.000 0.403 0.853
## .hcope 0.555 0.054 10.368 0.000 0.555 0.788
## .amphi 0.238 0.023 10.368 0.000 0.238 0.236
## .pcope 0.315 0.030 10.368 0.000 0.315 0.610
## .mysid 0.369 0.036 10.368 0.000 0.369 0.599
##
## R-Square:
## Estimate
## chla 0.147
## hcope 0.212
## amphi 0.764
## pcope 0.390
## mysid 0.401
summary(modfitN, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 49 iterations
##
## Optimization method NLMINB
## Number of free parameters 53
##
## Used Total
## Number of observations 207 312
##
## Estimator ML
## Model Fit Test Statistic 18.324
## Degrees of freedom 12
## P-value (Chi-square) 0.106
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.206 0.073 2.840 0.005 0.206 0.190
## hcope_1 -0.094 0.113 -0.827 0.408 -0.094 -0.061
## amphi_1 0.064 0.065 0.981 0.327 0.064 0.067
## corbic_1 0.003 0.059 0.053 0.958 0.003 0.004
## flow 0.078 0.075 1.043 0.297 0.078 0.075
## secchi -0.072 0.063 -1.142 0.254 -0.072 -0.081
## temp 0.425 0.203 2.099 0.036 0.425 0.147
## hcope ~
## chla_1 -0.017 0.035 -0.478 0.633 -0.017 -0.025
## hcope_1 0.158 0.072 2.179 0.029 0.158 0.165
## pcope_1 -0.074 0.039 -1.863 0.062 -0.074 -0.116
## mysid_1 0.062 0.050 1.224 0.221 0.062 0.097
## corbic_1 0.057 0.028 2.023 0.043 0.057 0.107
## flow -0.238 0.041 -5.873 0.000 -0.238 -0.370
## secchi -0.048 0.035 -1.361 0.174 -0.048 -0.086
## temp 0.297 0.106 2.800 0.005 0.297 0.166
## estfish_bsmt_1 0.026 0.047 0.553 0.580 0.026 0.035
## amphi ~
## chla_1 0.113 0.064 1.762 0.078 0.113 0.102
## amphi_1 0.525 0.057 9.144 0.000 0.525 0.533
## flow -0.003 0.067 -0.049 0.961 -0.003 -0.003
## secchi 0.011 0.055 0.195 0.845 0.011 0.012
## temp -0.163 0.176 -0.924 0.355 -0.163 -0.055
## estfish_bsmt_1 -0.115 0.077 -1.493 0.135 -0.115 -0.094
## pcope ~
## hcope_1 -0.085 0.123 -0.690 0.490 -0.085 -0.057
## pcope_1 0.260 0.067 3.913 0.000 0.260 0.264
## mysid_1 0.125 0.085 1.469 0.142 0.125 0.126
## corbic_1 0.031 0.051 0.606 0.544 0.031 0.037
## flow -0.055 0.069 -0.795 0.427 -0.055 -0.055
## secchi 0.215 0.060 3.582 0.000 0.215 0.251
## temp 0.214 0.182 1.177 0.239 0.214 0.077
## estfish_bsmt_1 -0.035 0.080 -0.440 0.660 -0.035 -0.031
## mysid ~
## hcope_1 0.021 0.111 0.187 0.852 0.021 0.014
## pcope_1 -0.056 0.060 -0.934 0.350 -0.056 -0.057
## mysid_1 0.209 0.076 2.749 0.006 0.209 0.210
## amphi_1 -0.093 0.047 -1.988 0.047 -0.093 -0.101
## flow -0.342 0.062 -5.480 0.000 -0.342 -0.341
## secchi -0.188 0.054 -3.461 0.001 -0.188 -0.220
## temp 0.330 0.162 2.039 0.041 0.330 0.119
## estfish_bsmt_1 0.082 0.071 1.144 0.253 0.082 0.072
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .hcope 0.025 0.023 1.113 0.266 0.025 0.078
## .amphi 0.004 0.038 0.096 0.924 0.004 0.007
## .pcope -0.039 0.039 -1.007 0.314 -0.039 -0.070
## .mysid 0.071 0.035 2.024 0.043 0.071 0.142
## .hcope ~~
## .amphi 0.008 0.020 0.408 0.683 0.008 0.028
## .pcope 0.054 0.021 2.645 0.008 0.054 0.187
## .mysid 0.116 0.020 5.830 0.000 0.116 0.443
## .amphi ~~
## .pcope -0.082 0.035 -2.333 0.020 -0.082 -0.164
## .mysid 0.034 0.031 1.098 0.272 0.034 0.077
## .pcope ~~
## .mysid 0.119 0.032 3.697 0.000 0.119 0.266
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.618 0.061 10.173 0.000 0.618 0.922
## .hcope 0.169 0.017 10.173 0.000 0.169 0.657
## .amphi 0.493 0.049 10.173 0.000 0.493 0.697
## .pcope 0.499 0.049 10.173 0.000 0.499 0.803
## .mysid 0.404 0.040 10.173 0.000 0.404 0.652
##
## R-Square:
## Estimate
## chla 0.078
## hcope 0.343
## amphi 0.303
## pcope 0.197
## mysid 0.348
summary(modfitS, standardized=T, rsq=T)
## lavaan 0.6-4 ended normally after 53 iterations
##
## Optimization method NLMINB
## Number of free parameters 52
##
## Used Total
## Number of observations 210 312
##
## Estimator ML
## Model Fit Test Statistic 19.526
## Degrees of freedom 13
## P-value (Chi-square) 0.108
##
## Parameter Estimates:
##
## Information Expected
## Information saturated (h1) model Structured
## Standard Errors Standard
##
## Regressions:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## chla ~
## chla_1 0.220 0.070 3.149 0.002 0.220 0.213
## hcope_1 0.148 0.117 1.271 0.204 0.148 0.085
## clad_1 0.204 0.074 2.759 0.006 0.204 0.188
## corbic_1 -0.013 0.057 -0.237 0.813 -0.013 -0.015
## flow -0.136 0.079 -1.717 0.086 -0.136 -0.121
## secchi -0.013 0.065 -0.193 0.847 -0.013 -0.013
## temp 0.209 0.229 0.913 0.361 0.209 0.059
## hcope ~
## chla_1 0.100 0.034 2.943 0.003 0.100 0.168
## hcope_1 0.291 0.061 4.757 0.000 0.291 0.290
## pcope_1 0.001 0.033 0.029 0.977 0.001 0.002
## corbic_1 0.059 0.030 1.980 0.048 0.059 0.113
## flow -0.178 0.040 -4.500 0.000 -0.178 -0.274
## secchi 0.046 0.034 1.359 0.174 0.046 0.080
## temp 0.326 0.118 2.757 0.006 0.326 0.161
## estfish_bsmt_1 -0.131 0.040 -3.262 0.001 -0.131 -0.190
## clad ~
## chla_1 0.155 0.055 2.810 0.005 0.155 0.162
## clad_1 0.513 0.059 8.653 0.000 0.513 0.511
## pcope_1 -0.021 0.051 -0.416 0.677 -0.021 -0.023
## flow 0.112 0.059 1.889 0.059 0.112 0.107
## secchi 0.013 0.052 0.242 0.809 0.013 0.014
## temp 0.426 0.185 2.303 0.021 0.426 0.130
## estfish_bsmt_1 -0.134 0.061 -2.206 0.027 -0.134 -0.121
## amphi ~
## chla_1 -0.025 0.067 -0.371 0.710 -0.025 -0.025
## amphi_1 0.208 0.067 3.094 0.002 0.208 0.205
## flow 0.061 0.074 0.830 0.407 0.061 0.055
## secchi -0.148 0.066 -2.222 0.026 -0.148 -0.152
## temp 0.274 0.234 1.171 0.242 0.274 0.079
## estfish_bsmt_1 0.062 0.080 0.778 0.436 0.062 0.053
## pcope ~
## chla_1 0.238 0.064 3.729 0.000 0.238 0.232
## hcope_1 -0.093 0.111 -0.837 0.403 -0.093 -0.053
## clad_1 0.056 0.070 0.809 0.419 0.056 0.052
## pcope_1 0.446 0.062 7.189 0.000 0.446 0.448
## corbic_1 -0.037 0.053 -0.697 0.486 -0.037 -0.041
## flow 0.045 0.073 0.616 0.538 0.045 0.040
## secchi 0.086 0.061 1.414 0.157 0.086 0.087
## temp 0.057 0.214 0.269 0.788 0.057 0.016
## estfish_bsmt_1 -0.065 0.073 -0.887 0.375 -0.065 -0.054
##
## Covariances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla ~~
## .hcope 0.034 0.022 1.518 0.129 0.034 0.105
## .clad 0.137 0.036 3.773 0.000 0.137 0.270
## .amphi 0.019 0.045 0.437 0.662 0.019 0.030
## .pcope -0.012 0.040 -0.300 0.764 -0.012 -0.021
## .hcope ~~
## .clad 0.029 0.018 1.610 0.107 0.029 0.112
## .amphi 0.018 0.023 0.783 0.434 0.018 0.054
## .pcope 0.014 0.020 0.696 0.487 0.014 0.048
## .clad ~~
## .amphi -0.065 0.036 -1.831 0.067 -0.065 -0.127
## .pcope 0.061 0.032 1.897 0.058 0.061 0.132
## .amphi ~~
## .pcope 0.017 0.041 0.413 0.679 0.017 0.029
##
## Variances:
## Estimate Std.Err z-value P(>|z|) Std.lv Std.all
## .chla 0.640 0.062 10.247 0.000 0.640 0.857
## .hcope 0.164 0.016 10.247 0.000 0.164 0.660
## .clad 0.402 0.039 10.247 0.000 0.402 0.628
## .amphi 0.652 0.064 10.247 0.000 0.652 0.908
## .pcope 0.531 0.052 10.247 0.000 0.531 0.713
##
## R-Square:
## Estimate
## chla 0.143
## hcope 0.340
## clad 0.372
## amphi 0.092
## pcope 0.287
#modificationindices(modfitS, sort=T, maximum.number=20)
#residuals(modfitW)
labelsfarwest=createLabels(modfitFW, cnameslag)
labelswest=createLabels(modfitW, cnameslag)
labelsnorth=createLabels(modfitN, cnameslag)
labelssouth=createLabels(modfitS, cnameslag)
#FAR WEST
myLavaanPlot(model=modfitFW, labels=labelsfarwest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#WEST
myLavaanPlot(model=modfitW, labels=labelswest,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#NORTH
myLavaanPlot(model=modfitN, labels=labelsnorth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
#SOUTH
myLavaanPlot(model=modfitS, labels=labelssouth,
node_options=list(shape="box", fontname="Helvetica"),
coefs=TRUE, stand=TRUE, covs=FALSE, sig=0.05,
width=c("regress","latent"),
color=c("regress","latent"))
Total effects
Haven’t done yet.